
#include <unistd.h>
#include "../logs/log.h"

using namespace define_log;

int main()
{
    // 测试记录

    // std::cout << UTIL::file::CreateDirctory("./info/man");
    // log_p::Formatter it;
    // log_p::message mess (log_p::log_level::values::DEBUG, "god", "hello");

    // //日志模块落地
    // auto tmp = it.GetResult(mess);
    // auto _c_sink = log_p::LogSinkFactory::CreateLogSink<log_p::CoutSink>();
    // auto _f_sink = log_p::LogSinkFactory::CreateLogSink<log_p::FileSink>("./log/testdata.log");
    // auto _f_size_sink = log_p::LogSinkFactory::CreateLogSink<log_p::RollFileBySizeSink>
    //     (1024 * 1024,"./log/test_by_size/testlog");
    // auto _f_time_sink = log_p::LogSinkFactory::CreateLogSink<log_p::RollFileByTimeSink>
    //     (log_p::time_gap::MINTUE,"./log/test_by_time/testlog");

    // _c_sink->log(tmp.c_str(), tmp.size());
    // _f_sink->log(tmp.c_str(), tmp.size());

    // time_t now = log_p::UTIL::TIME::GetTime();
    // int gap = 10;
    // auto time_ = now;
    // while (now != time_ + 33)
    // {
    //     _f_time_sink->log(tmp.c_str(), tmp.size());
    //     now = log_p::UTIL::TIME::GetTime();
    //     sleep(1);
    // }

    // log_p::SynLogger it("afeng_syn");
    // LOG_DEBUG(it, "test debug log %d", 111);
    // LOG_INFO(it, "test log %d", 111);
    // LOG_FAIL(it, "test log %d", 111);
    // LOG_WARN(it, "test log %d", 111);

    

    // log_p::log_level::values limit_level = log_p::log_level::values::DEBUG;
    // log_p::Formatter::ptr formatter_fty = std::make_shared<log_p::Formatter>();

    // auto _c_sink = log_p::LogSinkFactory::CreateLogSink<log_p::CoutSink>();
    // auto _f_size_sink_info = log_p::LogSinkFactory::CreateLogSink<log_p::RollFileBySizeSink>
    //         (1024 * 1024,"./log/log_by_size/log");

    // std::vector<log_p::LogSink::ptr> _sink_queue = {_c_sink, _f_size_sink_info};
    // log_p::Logger::ptr it(new log_p::SynLogger("afeng", limit_level, formatter_fty, _sink_queue));

    // log_p::buffer _pro_buffer;   // 生产者缓冲区
    // log_p::buffer _write_buffer; // 消费者缓冲区
    // _pro_buffer.push("auto tmp = logbuilder->build()");
    // std::cout << " " << _pro_buffer._write_cur <<std::endl;
    // std::cout << _pro_buffer._buffer[0] << std::endl;
    // _pro_buffer.swap(_write_buffer);
    // // std::cout << _write_buffer._buffer[0] << std::endl;
    // // std::cout << (void*)_write_buffer.GetWritePointer() << std::endl;
    // std::cout.write((char*)_write_buffer.GetReadPointer(), (sizeof (char)) * _write_buffer.GetWriteCur());

    // std::string test = "hahhhahha";
    // std::cout.write(test.c_str(), test.size());
    // std::cout << " " << _write_buffer._write_cur <<std::endl;

    // auto logbuilder = log_p::SingletonBuilderLogger::GetInstance("agan", log_p::SinkType::LOGGER_ASYN);
    // auto tmp = logbuilder->build();
    // std::cout << "Sing " << tmp << std::endl;
    // LOG_DEBUG(tmp, "test info %d", 111);
    // LOG_INFO(tmp, "hahhaha");
    // LOG_FAIL(tmp, "hahhaha");

    // log_p::LocalBuilderLogger Z("afeng", log_p::SinkType::LOGGER_ASYN);
    // auto tmpz = Z.build();
    // LOG_DEBUG(tmpz, "test info %d", 111);
    // LOG_INFO(tmpz, "hahhaha");
    // LOG_FAIL(tmpz, "hahhaha");

    InitOverAllLogger();

    DEBUG("test info %d", 111);
    INFO("hahhaha");
    FAIL("hahhaha");

    DEBUG("test info %d", 111);
    INFO("hahhaha");
    FAIL("hahhaha");

    int cursize = 0;
    int filenum = 0;
    while (filenum < 1024 * 24 )
    {
        INFO("test info %d", 111);
        WARN("test warn %d", 111);
        filenum++;
    }

    return 0;
}
